package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.StudentDao;
import com.itheima.domain.Student;
import com.itheima.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;

    @Override
    public PageInfo<Student> getAll(int page, int size) {
        PageHelper.startPage(page,size);
        List<Student> all = studentDao.getAll();
        return new PageInfo<Student>(all);
    }

    @Override
    public boolean save(Student stu) {
        return studentDao.save(stu);
    }

    @Override
    public boolean delete(Integer uuid) {
        return studentDao.delete(uuid);
    }

    @Override
    public boolean update(Student stu) {
        return studentDao.update(stu);
    }

    @Override
    public Student get(Integer uuid) {
        return studentDao.get(uuid);
    }


    @Override
    public Student login(String name, Integer age) {
        return studentDao.getByNameAndAge(name,age);
    }
}
